const http = require('http')
const fs = require('fs')
// var httpProxy = require('http-proxy')
// var proxy = httpProxy.createProxyServer();

/*var proxy_server = http.createServer(function(req, res) {
    if (req.url === '/index.html') {
        fs.readFile('index.html', (err, data) => {
            res.writeHead(200, {
                'Content-Type': 'text/html'
            })
            res.write(data.toString())
            res.end()
        })
    } else {
        proxy.web(req, res, {
            target: 'http://localhost:8000'
        });
    }
});

proxy_server.listen(4000, function() {
    console.log('proxy server is running ');
});*/

const server = http.createServer((req, res) => {
    console.log(req.url)
    if (req.url === '/index.html') {
        fs.readFile('index.html', (err, data) => {
            res.writeHead(200, {
                'Content-Type': 'text/html'
            })
            res.write(data.toString())
            res.end()
        })
    }
})

server.listen(4000)
